Migrate optional accelerator to FlashReg (replaces RidgeFast + RidgeCuda)#4
Open
psychemistz wants to merge 2 commits into
Open
Migrate optional accelerator to FlashReg (replaces RidgeFast + RidgeCuda)#4psychemistz wants to merge 2 commits into
psychemistz wants to merge 2 commits into
Conversation
…uda)
FlashReg is a single optional package providing both the C+OpenMP CPU
backend and the (optional) CUDA GPU backend. It replaces the historical
pair of RidgeFast (CPU) and RidgeCuda (GPU) packages — same kernel
sources, same MT19937 permutation seam, same bit-equivalence guarantees.
Changes:
- DESCRIPTION: Suggests drops RidgeFast + RidgeCuda, adds FlashReg.
- R/ridge.R: .resolve_backend / .ridge_dispatch / .ridge_batch_dispatch
now delegate to FlashReg::ridge() with backend mapping
gpu -> cuda_native
cpu-fast -> omp
cpu-pure -> in-house .ridge_pureR (unchanged)
Legacy SecAct backend names are preserved for backward compatibility.
.ridge_pureR_batch gains an injectable 'kernel_fn' argument so the
HDF5-streaming column-batch loop is shared between FlashReg and pure-R.
- R/activity.R: docstring updated to recommend FlashReg.
- tests/testthat/test-backend-parity.R: skip_if_not_installed('FlashReg').
- vignettes/accelerator.Rmd: replaces RidgeFast + RidgeCuda links with
FlashReg link and explanatory note.
Verified with FlashReg 0.1.0 installed:
SecAct backend='cpu-fast' (-> FlashReg backend='omp')
vs backend='cpu-pure':
max|delta beta| = 3.6e-17, max|delta z| = 6.7e-16, p exact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates SecAct's optional accelerator integration from the historical pair of RidgeFast (CPU) + RidgeCuda (GPU) R packages to a single unified FlashReg R package that ships both backends — same C + OpenMP kernel for CPU, same CUDA kernel for GPU, shared MT19937 permutation seam, single `configure` script that auto-detects `nvcc`.
Users get a simpler install story (one optional package instead of two) and the same bit-equivalence guarantee.
What changed
`DESCRIPTION` — `Suggests:` drops `RidgeFast` + `RidgeCuda`, adds `FlashReg`.
`R/ridge.R` — `.resolve_backend` / `.ridge_dispatch` / `.ridge_batch_dispatch` now delegate to `FlashReg::ridge()` with backend mapping:
Legacy SecAct backend names are preserved for backward compatibility — any downstream code that pins `backend="gpu"` or `backend="cpu-fast"` keeps working without changes.
`.ridge_pureR_batch` gains an optional `kernel_fn=` argument so the HDF5-streaming column-batch loop is now shared between FlashReg and the pure-R fallback.
`R/activity.R` — `backend` parameter docstring updated to recommend FlashReg.
`tests/testthat/test-backend-parity.R` — `skip_if_not_installed("FlashReg")`.
`vignettes/accelerator.Rmd` — RidgeFast + RidgeCuda installation links replaced with FlashReg link and a short explanatory note about the consolidation.
Why one package
FlashReg is the same kernel sources as RidgeFast + RidgeCuda, just reorganized:
Verification
Cross-backend parity verified end-to-end at the double-precision floor.
Through SecAct's dispatcher (FlashReg 0.1.0 installed, `n=60, p=10, m=4, nrand=200, seed=0`):
```
backend='cpu-fast' (-> FlashReg backend='omp')
vs backend='cpu-pure':
max|delta beta| = 3.6e-17
max|delta z| = 6.7e-16
exact pvalue match
```
End-to-end parity ledger across all backends:
Backward compatibility
Open coordination
This depends on FlashReg being published at `data2intelligence/FlashReg` so `Suggests: FlashReg` resolves. Happy to coordinate the release order with you — FlashReg is ready to push when the repo is created.
Test plan